import request from '@/utils/request'
import type { BannerItem, CategoryItem, HotItem, GuessData } from '../types/home'

enum API {
  // 首页轮播图
  HOME_BANNER_URL = '/home/banner',
  // 分类
  HOME_CATE_URL = '/home/category/mutli',
  // 热门推荐
  HOME_HOT_URL = '/home/hot/mutli',
  // 猜你喜欢
  HOME_GUESS_URL = '/home/goods/guessLike'
}

/**
 *
 * @param distributionSite 默认为1，请求的是首页的轮播图，2为分类的轮播图数据
 * @returns
 */
// 获取首页轮播图
export const reqHomeBanner = (distributionSite = 1) => {
  return request<BannerItem[]>({
    url: API.HOME_BANNER_URL,
    method: 'GET',
    data: {
      distributionSite
    }
  })
}
// 获取分类
export const reqHomeCategory = () => {
  return request<CategoryItem[]>({
    url: API.HOME_CATE_URL,
    method: 'GET'
  })
}
// 获取热门推荐
export const reqHomeHot = () => {
  return request<HotItem[]>({
    url: API.HOME_HOT_URL,
    method: 'GET'
  })
}
// 获取猜你喜欢
export const reqHomeGuess = (page = 1, pageSize = 10) => {
  return request<GuessData>({
    url: API.HOME_GUESS_URL,
    method: 'GET',
    data: {
      page,
      pageSize
    }
  })
}
